home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI2000
/
TI2720.ASC
< prev
Wrap
Text File
|
1994-10-03
|
2KB
|
94 lines
PRODUCT : Pascal NUMBER : 2720
VERSION : All
OS : DOS
DATE : September 30, 1994 PAGE : 1/2
TITLE : Using FindFirst and FindNext to find directories.
{
Finding directories using Pascal's FindFirst() and
FindNext() procedure can be a bit tricky. By default,
FindFirst() and FindNext() will find ALL files. Not
just directories. To determine if what FindFirst()
and FindNext() finds is really a directory, you must
check the Attr field of the SearchRec to determine
if the attribute indicates that the element is a
directory.
The following program adds only directory names to an
array of strings.
}
program FindIt;
uses DOS;
const
ArrayLimit = 512;
type
DOSFileName = String[12];
var
SR: SearchRec;
A: array[1..ArrayLimit] of DOSFileName;
i: integer;
begin
i := 1;
{ find the first directory }
FindFirst('c:\*.*', Directory, SR);
{ check for an error }
If DosError = 0 then begin
repeat
{ is it really a directory? }
if (SR.Attr and Directory) <> 0 then begin
PRODUCT : Pascal NUMBER : 2720
VERSION : All
OS : DOS
DATE : September 30, 1994 PAGE : 2/2
TITLE : Using FindFirst and FindNext to find directories.
A[i] := SR.Name; { add dir to array }
i := i + 1; { increment index }
end;
FindNext(SR); { find next directory }
{ exit loop if a DOS error occurs }
until DosError <> 0;
end
else
{ Write error if FindFirst() fails }
Writeln('Can''t do it. Error code: ', DOSError);
end.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.